import AsyncComponent from '@/framework/FormMaking/components/AsyncComponent/index';
import YchConstant from "@/api/YchConstant";

export const PortletSettingMixin = {
  components: {
    AsyncComponent
  },
  data () {
    return {
      /* 门户配置设计数据 */
      portalDesignData: null,
      /* 门户配置默认配置数据 */
      defaultWidgetForm: {
        list: [],
        config: { labelWidth: 100, labelPosition: 'right', size: 'small' }
      },
      /* 门户配置列表弹窗ref名称 */
      tabsDropRefName:'tabsDropRefName',
      /* 门户配置列表显隐控制 */
      showDrop:false,
      /* 门户配置修改content接口 */
      updateForPortletUrl:YchConstant.PREFIX_SYSTEM + '/portlet/updatePortlet',
      /* 门户配置信息 */
      portLet:{},
      /* 门户配置操作类型*/
      handleType:"init",
      /* 保存门户配置JSon  */
      content:"",
      /* 设计器弹窗显隐控制  */
      showEditIndexModal:false,
      /* 设计器弹窗ref名称 */
      portalDesignRefName:'portalDesignRefName',
      /* 设计器路径  */
      portalDesignPath:'framework/FormMaking/components/portletDesign/PortalDesignModal'
    }
  },
   computed: {
    widgetForm() {
      let widgetForm = {}
      widgetForm = this.content
      //widgetForm.config["id"] = this.portLet.id //保存门户配置id
      // 门户小页权限过滤
      return widgetForm
    }
  },
  methods: {
    /*更新门户配置设计数据 */
    updateDesign(data) {
      this.portalDesignData = data
    },
    /*打开门户桌面设计器*/
    openPortalDesign(res) {
      this.portLet = res
      if(res.content){
        this.handleType = "edit"
        this.content = JSON.parse(res.content)
      }else {
        this.handleType = "add"
        this.content = this.defaultWidgetForm
      }
      this.showEditIndexModal = true
    },
    // 设计器关闭事件
    handeleCloseDesignMd() {
      this.showEditIndexModal = false
    },
    /*删除操作更新tabsDropRefName列表*/
    updatePortLetList() {
      // this.closeModal()
      this.handeleCloseDesignMd()  //关闭设计器弹窗
      //this.$refs[this.tabsDropRefName][0].refreshData()
    }
  }
}
